package pro.cherish.knowledgeormmysql.controller;

import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pro.cherish.knowledgeormmysql.entity.Teacher;
import pro.cherish.knowledgeormmysql.entity.User;
import pro.cherish.knowledgeormmysql.mapper.UserMapper;
import pro.cherish.knowledgeormmysql.service.UserService;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author 创建人：cherish
 * @version 版本号：V1.0
 * <p>
 * ***************************修订记录************************************
 * 2019-11-08 cherish 创建该类功能。
 * **********************************************************************
 * </p>
 * @ClassName 类名：UserController
 * @Description 功能说明：
 * <p>
 * TODO
 * </p>
 * **********************************************************************
 * @date 创建日期： 2019-11-08 cherish
 */
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @Autowired
    private UserMapper userMapper;

    @RequestMapping("/user/select")
    public Object  select(){
        List<User> list = userService.list();
        return list;
    }
    @RequestMapping("/user/insert")
    public Object insert(String name,Integer age){
        User user = User.builder().birthday(LocalDateTime.now()).build();
        boolean result = userService.save(user);
        return  result;
    }

    @RequestMapping("/user/deleteAll")
    public void delAll(){
        userMapper.deleteAll();
    }
}
